﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class MicroWebsiteOrderLogDetail
    {
        private readonly Chain.IDAL.MicroWebsiteOrderLogDetail dal = new Chain.IDAL.MicroWebsiteOrderLogDetail();

        public int Add(Chain.Model.MicroWebsiteOrderLogDetail model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.MicroWebsiteOrderLogDetail> DataTableToList(DataTable dt)
        {
            List<Chain.Model.MicroWebsiteOrderLogDetail> list = new List<Chain.Model.MicroWebsiteOrderLogDetail>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.MicroWebsiteOrderLogDetail item = new Chain.Model.MicroWebsiteOrderLogDetail();
                    if ((dt.Rows[i]["MicroOrderLogDetailID"] != null) && (dt.Rows[i]["MicroOrderLogDetailID"].ToString() != ""))
                    {
                        item.MicroOrderLogDetailID = int.Parse(dt.Rows[i]["MicroOrderLogDetailID"].ToString());
                    }
                    if ((dt.Rows[i]["MicroOrderID"] != null) && (dt.Rows[i]["MicroOrderID"].ToString() != ""))
                    {
                        item.MicroOrderID = int.Parse(dt.Rows[i]["MicroOrderID"].ToString());
                    }
                    if ((dt.Rows[i]["MicroGoodsID"] != null) && (dt.Rows[i]["MicroGoodsID"].ToString() != ""))
                    {
                        item.MicroGoodsID = int.Parse(dt.Rows[i]["MicroGoodsID"].ToString());
                    }
                    if ((dt.Rows[i]["MicroOrderDetailPrice"] != null) && (dt.Rows[i]["MicroOrderDetailPrice"].ToString() != ""))
                    {
                        item.MicroOrderDetailPrice = decimal.Parse(dt.Rows[i]["MicroOrderDetailPrice"].ToString());
                    }
                    if ((dt.Rows[i]["MicroOrderDetailPoint"] != null) && (dt.Rows[i]["MicroOrderDetailPoint"].ToString() != ""))
                    {
                        item.MicroOrderDetailPoint = int.Parse(dt.Rows[i]["MicroOrderDetailPoint"].ToString());
                    }
                    if ((dt.Rows[i]["MicroOrderDetailDiscountPrice"] != null) && (dt.Rows[i]["MicroOrderDetailDiscountPrice"].ToString() != ""))
                    {
                        item.MicroOrderDetailDiscountPrice = decimal.Parse(dt.Rows[i]["MicroOrderDetailDiscountPrice"].ToString());
                    }
                    if ((dt.Rows[i]["MicroOrderDetailNumber"] != null) && (dt.Rows[i]["MicroOrderDetailNumber"].ToString() != ""))
                    {
                        item.MicroOrderDetailNumber = int.Parse(dt.Rows[i]["MicroOrderDetailNumber"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int MicroOrderLogDetailID)
        {
            return this.dal.Delete(MicroOrderLogDetailID);
        }

        public bool DeleteList(string MicroOrderLogDetailIDlist)
        {
            return this.dal.DeleteList(MicroOrderLogDetailIDlist);
        }

        public bool Exists(int MicroOrderLogDetailID)
        {
            return this.dal.Exists(MicroOrderLogDetailID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public DataSet GetListSP(string strWhere)
        {
            return this.dal.GetListSP(strWhere);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.MicroWebsiteOrderLogDetail GetModel(int MicroOrderLogDetailID)
        {
            return this.dal.GetModel(MicroOrderLogDetailID);
        }

        public List<Chain.Model.MicroWebsiteOrderLogDetail> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.MicroWebsiteOrderLogDetail model)
        {
            return this.dal.Update(model);
        }
    }
}

